<template>
  <div>
    <div class="evaluate-shop">
      <div class="evaluate-shop-left">
        <div class="evaluate-shop-img" v-if="shop.smImageUrl" :style="'backgroundImage: url('+(shop.smImageUrl.substr(0,4).toLowerCase() == 'http' ? shop.smImageUrl : resUrl+shop.smImageUrl)+')'"></div>
        <div class="evaluate-shop-title">
          <h3>{{shop.name}}</h3>
          <span style="    background-color: rgb(197, 0, 0);
    color: rgb(255, 255, 255);
    font-size: 10px;
    height: 13px;
    line-height: 13px;
    padding: 0 5px;"
          >店铺认证</span>
        </div>
      </div>
      <div class="evaluate-shop-right">{{shop.level}}</div>
    </div>

    <div class="evaluate-main">
      <div class="evaluate-star">
        <i class="icon icon-star" v-for="(v,k) in starArr" :key="k" :class="{active:k<evaluate.val}"></i>
      </div>
      <div class="evaluate-explain text-red">{{evaluate.name}}</div>
    </div>
    <div class="evaluate-content">
      <p>评论内容</p>
      <p>{{evaluateContent}}</p>
    </div>

    <div class="btn-box">
      <button class="weui-btn weui-btn_warn" type="button" @click="subEvaluate">确认</button>
    </div>

  </div>
</template>

<script>
  import {ipconfig} from '../../../../assets/js/ipconfig';
  import {getStatusMapByKey,getStatusByKeyVal} from '../../../../assets/js/tools';
  import {getShopDetail,getEvaluate} from '../../../../assets/js/getData';
  export default {
    name: "viewEvaluate",
    data(){
      return {
        resUrl:ipconfig.resUrl,//图片、视频、音频等资源访问路径
        starArr:new Array(5),
        shopId:null,
        orderId:null,
        evaluate:{},
        evaluateContent:'',
        shop:{},
      }
    },
    created(){
      this.shopId = this.$route.query.shopId;
      this.orderId = this.$route.query.orderId;

      getShopDetail({id:this.shopId}).then(res => {
        if(res.data.reqResult.code>0){
          this.shop = res.data.data;
          // console.log(this.shop)
        }else {
          Toast(res.data.reqResult.msg);
        }
      });
      getEvaluate(this.orderId).then(res => {
        if(res.data.reqResult.code>0){
          console.log(res);
          this.evaluateContent = res.data.data.content;
          this.evaluate = getStatusByKeyVal('eEvaluateType',res.data.data.level);
          // console.log(this.evaluate)
        }else {
          Toast(res.data.reqResult.msg);
        }
      });
    },
    methods:{
      subEvaluate(){
        this.$router.go(-1);
      }
    }
  }
</script>

<style scoped>
  .evaluate-shop{
    display: flex;
    justify-content: space-between;
    height: 5.05rem;
    padding-left: 0.9rem;
    padding-right: 1.7rem;
    align-items: center;
    border-bottom: 1px solid #EEEEEE;
  }
  .evaluate-shop-left{
    display: flex;
    align-items: center;
  }
  .evaluate-shop-img{
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    margin-right: 0.55rem;
    background-origin: content-box;
    background-position:50% 50%;
    background-size:contain;
    background-repeat:no-repeat;
    background-color: rgba(0,0,0,0.2);
  }
  .evaluate-shop-img img{
    width: 100%;
  }
  .evaluate-shop-title{
    display: flex;
    align-items: center;
  }
  .evaluate-shop-title h3{
    color: #282828;
    font-size: 0.75rem;
    line-height: 0.75rem;
    margin-right: 0.2rem;
  }
  .evaluate-shop-right{
    padding-left: 1rem;
    background-image: url("../../../../../static/images/order/star.png");
    background-repeat: no-repeat;
    background-size: 0.7rem 0.65rem;
    background-position: left center;
  }
  .evaluate-main{
    padding: 1rem 1.7rem 0 1.7rem;
  }
  .evaluate-star{
    display: flex;
    justify-content: space-around;
  }
  .icon-star {
    font-size: 1.4rem;
    color: #CCCCCC;
  }
  .icon-star.active{
    color: #F9B523;
  }
  .evaluate-explain{
    color: #666666;
    font-size: 0.75rem;
    text-align: center;
    margin:1.25rem 0;
  }
  .text-red{
    color: #C50000;
  }
  .evaluate-content{
    padding: 0.4rem 0.95rem;
  }
  .evaluate-content p{
    color: #333333;
    font-size: 0.7rem;
  }
  .evaluate-content p:last-child{
    line-height: 0.85rem;
    padding: 1rem 1.35rem;
  }
  .btn-box{
    padding: 0 2.2rem;
    position: absolute;
    bottom: 1.35rem;
    left: 0;
    right: 0;
  }

</style>
